package com.fanhang.samples.spring.security.po;

import java.util.Arrays;
import java.util.List;

import org.springframework.util.StringUtils;

import com.fanhang.samples.spring.security.po.tbl.UserTbl;

public class User extends UserTbl {
	private static final long serialVersionUID = 1L;
	
	public static List<String[]> userList = Arrays.asList(
			new String[] { "1", "zhangsan", "zs", "ADMIN,USER" }, 
			new String[] { "2", "lisi", "ls", "USER" }, 
			new String[] { "3", "wangwu", "ww", "" }
		);
	
	private List<String> roles;
	
	
	
	
	public List<String> getRoles() {
		return roles;
	}
	public void setRoles(List<String> roles) {
		this.roles = roles;
	}
	
	@Override
	public void setRoleString(String roleString) {
		super.setRoleString(roleString);
		// 设置角色字符串的同时, 分割出角色列表并设置到roles
		if (StringUtils.hasText(roleString)) {
			String[] roles = StringUtils.split(roleString, ",");
			this.setRoles(Arrays.asList(roles));
		}
	}
}
